﻿Imports System.Data.OleDb
Public Class createevents
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub


    Protected Sub btn_save_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_save.Click
        Dim sql As String = "INSERT INTO events (eventname, venue, cars_to_use, event_planner, date_and_time) VALUES(@a1,@a2,@a3,@a4,@a5)"
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("mercedesbenzconnectionstring").ConnectionString)
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@a1", TextBox1.Text)
        cmd.Parameters.AddWithValue("@a2", TextBox2.Text)
        cmd.Parameters.AddWithValue("@a3", TextBox3.Text)
        cmd.Parameters.AddWithValue("@a4", User.Identity.Name)
        cmd.Parameters.AddWithValue("@a5", DateTime.Parse(TextBox4.Text & " " & DropDownList1.SelectedItem.Text & ":" & TextBox5.Text & ":" & TextBox6.Text & " " & DropDownList2.SelectedItem.Text))

        conn.Open()

        If (cmd.ExecuteNonQuery()) Then
            conn.Close()
            cmd.Dispose()
            conn.Dispose()
            MsgBox("Record saved!!!", MsgBoxStyle.Exclamation)
        Else
            MsgBox("Sorry, your Event has not been saved.Check and be sure there s no mistake somewhere!!!", MsgBoxStyle.Exclamation)
            TextBox1.Focus()
            Return
        End If
    End Sub
End Class